<?php

declare(strict_types=1);

namespace Dreamcat\ApiDocTest\TestCases;

use Dreamcat\ApiDoc\Error\PopoException;
use Dreamcat\ApiDoc\Popo\ApiDefinition;
use Dreamcat\ApiDoc\Popo\BodyDefinition;
use PHPUnit\Framework\TestCase;

/**
 * 异常类测试
 * @author vijay
 */
class ErrorTest extends TestCase
{
    public function testBodyAddErrorObject()
    {
        $this->expectException(PopoException::class);
        $this->expectExceptionMessage("对象属性必须定义字段名");
        $body = new BodyDefinition();
        $child = new BodyDefinition();
        $body->addObjectProperty($child);
    }

    public function testApiAddGetErrorObject()
    {
        $this->expectException(PopoException::class);
        $this->expectExceptionMessage("Get 对象属性必须定义字段名");
        $body = new ApiDefinition();
        $child = new BodyDefinition();
        $body->addGetDefinition($child);
    }

    public function testApiAddPathErrorObject()
    {
        $this->expectException(PopoException::class);
        $this->expectExceptionMessage("Path Variable 对象属性必须定义字段名");
        $body = new ApiDefinition();
        $child = new BodyDefinition();
        $body->addPathVariableDefinition($child);
    }

    public function testApiAddHeaderErrorObject()
    {
        $this->expectException(PopoException::class);
        $this->expectExceptionMessage("Header 对象属性必须定义字段名");
        $body = new ApiDefinition();
        $child = new BodyDefinition();
        $body->addHeaderDefinition($child);
    }

    public function testApiAddCookieErrorObject()
    {
        $this->expectException(PopoException::class);
        $this->expectExceptionMessage("Cookie 对象属性必须定义字段名");
        $body = new ApiDefinition();
        $child = new BodyDefinition();
        $body->addCookieDefinition($child);
    }
}

# end of file
